<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>箭头函数</title>
</head>
<body>
    <script>
        var a = 0;
        function foo(){
            var that = this;
            console.log(that, '外层函数的this');

            // function test(){
            //     console.log(that, '外层函数的that');
            //     console.log(this, '内层函数的this');
            // }
            // test.call(obj);
            var test = () => { // 箭头函数本身是没有this指向的，它的this指向是上层作用域中的this
                console.log(this, '箭头函数的this')
            }
            test();
        }

        var obj = {
            a: 1,
            foo: foo
        }
        obj.foo();
    </script>
</body>
</html>